/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package apirose;

import apirose.APIMain;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author v-tech_master
 */
class Main_MySQL implements APIMain {
    
    private Request_MySQL bdd;
    private int idPromotion;

    public Main_MySQL(Request_MySQL request, int idPromo) {
        this.bdd = request;
        this.idPromotion = idPromo;
    }

    public ArrayList<Integer> getListIdEtudiantBDD() {
        ArrayList<Integer> listeId = new ArrayList<Integer>();
        
        String req = "SELECT id FROM Etudiant WHERE idPromotion = "+this.idPromotion+";";
        
        ResultSet rs = bdd.executer_requete(req);
        try {
            while(rs.next()){
                listeId.add(rs.getInt("id"));
            }
        } catch (SQLException ex) {
            Logger.getLogger(Main_MySQL.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        return listeId;
    }

    //TODO
    public ArrayList<Integer> getListeIdEnseignantBDD() {
        ArrayList<Integer> listeId = new ArrayList<Integer>();
        
        String req = "SELECT DISTINCT idIntervenant FROM V_Infos_Seance_Pomotion WHERE idPromotion = "+this.idPromotion+";";
        
        ResultSet rs = bdd.executer_requete(req);
        try {
            while(rs.next()){
                listeId.add(rs.getInt("idIntervenant"));
            }
        } catch (SQLException ex) {
            Logger.getLogger(Main_MySQL.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        return listeId;
    }

    public ArrayList<Integer> getListIdUEBDD() {
        ArrayList<Integer> listeId = new ArrayList<Integer>();
        
        String req = "SELECT id FROM UE WHERE idPromotion = "+this.idPromotion+";";
        
        ResultSet rs = bdd.executer_requete(req);
        try {
            while(rs.next()){
                listeId.add(rs.getInt("id"));
            }
        } catch (SQLException ex) {
            Logger.getLogger(Main_MySQL.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        return listeId;
    }

   
    
}
